package com.factory.statictime;

class Bowl {
    Bowl(int marker) {
        System.out.println("Bowl(" + marker + ")");
    }
}
 
class Tableware {
    static Bowl bowl = new Bowl(3);
    static {
        System.out.println("Tableware静态代码块");
    }
    Tableware() {
        System.out.println("Tableware构造器");
    }
    Bowl bowl2 = new Bowl(8);
}
 
class Table extends Tableware {
    {
        System.out.println("Table非静态代码块1");
    }
    Bowl bowl = new Bowl(2);
    {
        System.out.println("Table非静态代码块2");
    }
    Table() {
        System.out.println("Table构造器");
    }
    static Bowl bowl1 = new Bowl(1);
    static {
        System.out.println("Table静态代码块1");
    }
    static Bowl bowl4 = new Bowl(4);
}
 
class Cupboard extends Tableware {
    Bowl bowl = new Bowl(5);
    static Bowl bowl6 = new Bowl(6);
    Cupboard() {
        System.out.println("Cupboard构造器");
    }
    void method(int n) {
        System.out.println("method(" + n +")");
    }
}


/**
 * Java初始化顺序
 * @author qinye
 * @date
 */
public class StaticInitTest {
    public static void main(String[] args) {
        System.out.println("main()");
        cupboard.method(9);
    }
    static Table table = new Table();
    static Cupboard cupboard = new Cupboard();
}